package com.huawei.appmarket.service.appmgr.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
import com.huawei.appgallery.foundation.service.common.protocol.request.AppListFragmentRequest;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.updatemanager.api.UpdateMgrFragmentProtocol;
import com.huawei.appgallery.updatemanager.api.UpdateMgrFragmentProtocol.Request;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import o.dgh;
import o.dji;
import o.djp;
import o.Logger;
import o.dsm;
import o.dss;
import o.dug;
import o.eiw;
import o.etz;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class AppUpdateActivity extends BaseActivity<AppManagerProtocol> implements eiw {
    private boolean ˊॱ = false;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (getActionBar() != null) {
            getActionBar().hide();
        }
        setContentView(h.ˊᐨ);
        dss.ॱ().ˊ(this);
        ͺ();
        ᐝॱ();
        ᐝ();
    }

    public void onResume() {
        long ˏ = dss.ॱ().ˏ();
        if (ˏ == 0 || ˏ + 1800000 < System.currentTimeMillis()) {
            Logger.ˎ("AppUpdateActivity", "onResume get online upgrade");
            dug.ˊ(getApplicationContext());
        }
        super.onResume();
    }

    private void ᐝ() {
        djp.ˎ().ˊ(true);
        dji.ˊ("customColumn.managercenter", false);
        dsm.ˏ().ˎ(false);
    }

    public void onDestroy() {
        super.onDestroy();
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (4 == i && this.ˊॱ) {
            finish();
            Intent intent = new Intent("android.intent.action.MAIN");
            intent.setFlags(268435456);
            intent.addCategory("android.intent.category.HOME");
            startActivity(intent);
        }
        return super.onKeyDown(i, keyEvent);
    }

    private void ͺ() {
        etz.ˎ().ˎ("last_view_app_update_fragment", Long.parseLong(new SimpleDateFormat("yyyyMMdd", Locale.US).format(new Date())));
        ॱˊ();
    }

    private void ॱˊ() {
        SafeIntent safeIntent = new SafeIntent(getIntent());
        if (getIntent() != null) {
            Object ˏ;
            String ˋ;
            String stringExtra = safeIntent.getStringExtra("eventkey");
            String stringExtra2 = safeIntent.getStringExtra("eventvalue");
            this.ˊॱ = safeIntent.getBooleanExtra("isFromAppManager", false);
            AppManagerProtocol appManagerProtocol = (AppManagerProtocol) ʾ();
            if (appManagerProtocol != null) {
                ˏ = appManagerProtocol.ˊ().ˏ();
                ˋ = appManagerProtocol.ˊ().ˋ();
            } else {
                ˋ = stringExtra2;
                stringExtra2 = stringExtra;
            }
            if (!TextUtils.isEmpty(ˏ)) {
                dgh.ॱ(this, ˏ, ˋ);
            }
            if (safeIntent.getBooleanExtra("isFromShortCut", false)) {
                dgh.ॱ(getApplicationContext(), "070306", KeyAndValue.NUMBER_01);
            }
        }
    }

    private void ᐝॱ() {
        AppListFragmentRequest request = new Request();
        request.ˎ(n.ʽᐝ);
        request.ʽ(KeyAndValue.NUMBER_01);
        request.ˊ(0);
        request.ॱ("070103");
        request.ˎ(true);
        request.ˋ(2);
        UpdateMgrFragmentProtocol updateMgrFragmentProtocol = new UpdateMgrFragmentProtocol();
        updateMgrFragmentProtocol.ˏ(request);
        ((TaskFragment) dss.ॱ().ˊ(updateMgrFragmentProtocol)).ˋ(ˏॱ(), j.ꜟͺ, "updatemgr.activity");
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }
}
